package tnviet.proj.jna;

import tnviet.proj.jna.analyzer.*;
import java.util.*;
import tnviet.proj.jna.analyzer.JNPacketAnalyzer;



public class JNPacketAnalyzerLoader
{
	static Vector analyzers=new Vector();

	static void loadDefaultAnalyzer(){
            analyzers.removeAllElements();
            analyzers.addElement(new PacketAnalyzer());
            analyzers.addElement(new EthernetAnalyzer());
            analyzers.addElement(new ARPAnalyzer());
            analyzers.addElement(new IPv4Analyzer());
            analyzers.addElement(new IPv6Analyzer());
            analyzers.addElement(new TCPAnalyzer());
            analyzers.addElement(new UDPAnalyzer());
            analyzers.addElement(new ICMPAnalyzer());
            analyzers.addElement(new HTTPAnalyzer());
            analyzers.addElement(new FTPAnalyzer());
            analyzers.addElement(new TelnetAnalyzer());
            analyzers.addElement(new SSHAnalyzer());
            analyzers.addElement(new SMTPAnalyzer());
            analyzers.addElement(new DNSAnalyzer());
            analyzers.addElement(new POP3Analyzer());
	}

	public static JNPacketAnalyzer[] getAnalyzers(){
            loadDefaultAnalyzer();
            JNPacketAnalyzer[] array=new JNPacketAnalyzer[analyzers.size()];

            for(int i=0;i<array.length;i++)
                    array[i]=(JNPacketAnalyzer)analyzers.elementAt(i);
            return array;
	}

	public static JNPacketAnalyzer[] getAnalyzersOf(int layer){
            loadDefaultAnalyzer();
            Vector v=new Vector();

            for(int i=0;i<analyzers.size();i++)
                    if(((JNPacketAnalyzer)analyzers.elementAt(i)).layer==layer)
                            v.addElement(analyzers.elementAt(i));

            JNPacketAnalyzer[] res=new JNPacketAnalyzer[v.size()];
            for(int i=0;i<res.length;i++)
                    res[i]=(JNPacketAnalyzer)v.elementAt(i);

            return res;
	}
}
